package com.anlu.pattern.structrue.proxy.demo1;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * <p>
 *
 * @author anlu
 * @date 2022/10/12 0012 21:53
 */
public class Client {
    public static void main(String[] args) {
        Subject rs = new OrangeSubject();
        InvocationHandler handler = new DynamicSubject(rs);
        Class cls = rs.getClass();

        //以下是一次性生成
        Subject subject = (Subject) Proxy.newProxyInstance(cls.getClassLoader(),cls.getInterfaces(), handler);
        subject.request();

    }
}
